<template>
	<view
		:style="themeColor"
		style="overflow-x: hidden;"
	>
		<view class="page">
			<view
				class="flex align-stretch benben-position-layout flex address_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }"
			>
				<view class='flex align-center justify-between flex-sub address_fd0_0'>
					<view
						class='flex align-center address_fd0_0_c0'
						@tap.stop="handleJumpDiy"
						data-type="back"
						data-url="1"
					>
						<text class='fu-iconfont2  address_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex align-center'>
						<text
							class='address_fd0_0_c1_c0'
							style="font-family: Alimama DongFangDaKai, Alimama DongFangDaKai;"
						>地址管理</text>
					</view>
					<view class='flex align-center address_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>

			<view class="flex flex-direction align-stretch benben-flex-layout address_flex_1">
				<view
					v-for="(item,i) in addressData"
					:key="i"
					:style="'animation-duration:'+item.animationTime+'s;'"
					class='flex flex-direction align-stretch address_fd1_0 animation-slide-right'
					@tap.stop="handleClickFunc(item.address_id)"
				>
					<view class='flex flex-direction align-stretch'>
						<view class='flex flex-wrap align-center address_fd1_0_c0_c0'>
							<view class='flex flex-wrap align-center address_fd1_0_c0_c0_c0'>
								<text
									class='address_fd1_0_c0_c0_c0_c0'
									style="font-family: PingFang SC, PingFang SC;"
								>{{item.label_name}}</text>
							</view>
							<text
								class='address_fd1_0_c0_c0_c1'
								style="font-family: Source Han Sans CN, Source Han Sans CN;"
							>{{item.name}}</text>
							<text class='address_fd1_0_c0_c0_c2'>(</text>
							<text
								style="font-family: Source Han Sans CN, Source Han Sans CN;"
								class='address_fd1_0_c0_c0_c2'
								v-if="item.sex=='1'"
							>先生</text><text
								style="font-family: Source Han Sans CN, Source Han Sans CN;"
								class='address_fd1_0_c0_c0_c2'
								v-if="item.sex!='1'"
							>女士</text>
							<text class='address_fd1_0_c0_c0_c2'>)</text>
							<text
								class='flex-sub address_fd1_0_c0_c0_c5'
								style="font-family: font-family: SF Pro Text, SF Pro Text;"
							>{{item.mobile}}</text>
						</view>
						<view>
							<text
								class='address_fd1_0_c0_c1_c0'
								style="font-family: Source Han Sans CN, Source Han Sans CN;"
							>{{item.province}}</text>
							<text
								class='address_fd1_0_c0_c1_c0'
								style="font-family: Source Han Sans CN, Source Han Sans CN;"
							>{{item.city}}</text>
							<text
								class='address_fd1_0_c0_c1_c0'
								style="font-family: Source Han Sans CN, Source Han Sans CN;"
							>{{item.district}}</text>
							<text
								class='address_fd1_0_c0_c1_c0'
								style="font-family: Source Han Sans CN, Source Han Sans CN;"
							>{{item.address}}</text>
						</view>
						<view class='flex align-center justify-between address_fd1_0_c0_c2'>
							<view
								class='flex flex-wrap align-center'
								@tap.stop="SelectDefaultFunc(item.address_id,item)"
							>
								<image
									class='address_fd1_0_c0_c2_c0_c0'
									mode="aspectFit"
									:src='STATIC_URL+"689.png"'
									v-if="item.is_default=='1'"
								></image>
								<image
									class='address_fd1_0_c0_c2_c0_c0'
									mode="aspectFit"
									:src='STATIC_URL+"690.png"'
									v-if="item.is_default=='0'"
								></image>
								<text
									class='address_fd1_0_c0_c2_c0_c1'
									style="font-family: Source Han Sans CN, Source Han Sans CN;"
								>默认地址</text>
							</view>
							<view class='flex flex-wrap align-center'>
								<view
									class='flex flex-wrap align-center'
									@tap.stop="getAddressIdFunc(item.address_id)"
								>
									<image
										class='address_fd1_0_c0_c2_c1_c0_c0'
										mode="aspectFit"
										:src='STATIC_URL+"6.png"'
									></image>
									<text
										class='address_fd1_0_c0_c2_c1_c0_c1'
										style="font-family: Source Han Sans CN, Source Han Sans CN;"
									>删除</text>
								</view>
								<view
									class='flex flex-wrap align-center address_fd1_0_c0_c2_c1_c1'
									@tap.stop="handleJumpDiy"
									data-type="navigateTo"
									:data-url="`/pages/yhq/editAddress/editAddress?id=${item.address_id}`"
								>
									<image
										class='address_fd1_0_c0_c2_c1_c0_c0'
										mode="aspectFit"
										:src='STATIC_URL+"7.png"'
									></image>
									<text
										class='address_fd1_0_c0_c2_c1_c0_c1'
										style="font-family: Source Han Sans CN, Source Han Sans CN;"
									>编辑</text>
								</view>
							</view>
						</view>
					</view>
				</view>

				<fu-empty v-if="addressLoading"></fu-empty>
				<fu-empty-ui v-else-if="empty"></fu-empty-ui>

				<view class='flex flex-wrap align-center justify-center address_fd1_1'>
					<button
						style="font-family: Alimama DongFangDaKai, Alimama DongFangDaKai;"
						class='address_fd1_1_c0'
						@tap.stop="handleJumpDiy"
						data-type="navigateTo"
						:data-url="`/pages/yhq/editAddress/editAddress`"
					>添加地址</button>
				</view>
			</view>


			<benben-popup
				v-model="popupShow1698316415254"
				:mask="true"
				:mask-close-able="true"
				mode='center'
				:z-index='999'
			>
				<!---flex布局flex布局开始-->
				<view class="flex benben-flex-layout flex-wrap align-center">
					<view class='flex flex-direction flex-wrap align-stretch address_fd2_0'>
						<view class='flex flex-direction flex-wrap align-center'>
							<text
								class='address_fd2_0_c0_c0'
								style="font-family: Alimama DongFangDaKai, Alimama DongFangDaKai;"
							>提示</text>
							<text
								class='address_fd2_0_c0_c1'
								style="font-family: Alimama DongFangDaKai, Alimama DongFangDaKai;"
							>确定删除该地址？</text>
							<view class='flex flex-wrap align-center address_fd2_0_c0_c2'>
								<view
									class='flex flex-wrap align-center justify-center address_fd2_0_c0_c2_c0'
									@click="closeModal"
								>
									<text
										class='address_fd2_0_c0_c2_c0_c0'
										style="font-family: Alimama DongFangDaKai, Alimama DongFangDaKai;"
									>取消</text>
								</view>
								<view
									class='flex flex-wrap align-center justify-center address_fd2_0_c0_c2_c1'
									@tap.stop="deleteAddressFunc()"
								>
									<text
										class='address_fd2_0_c0_c2_c1_c0'
										style="font-family: Alimama DongFangDaKai, Alimama DongFangDaKai;"
									>确认</text>
								</view>
							</view>
						</view>
					</view>
				</view>

				<!---flex布局flex布局结束-->

			</benben-popup>

		</view>
	</view>
</template>
<script>
	import pagingList from '@/common/mixin/paging_list.js';
	import { validate } from '@/common/utils/validate.js'
	import { addressModuleMixin } from './addressModuleMixin'
	export default {
		components: {},
		mixins: [addressModuleMixin],

		data() {
			return {
				changeDefLoading: false,
				"popupShow1698316415254": false,
				"minixPagingListsApi": "",
				"pageingListApiMethod": "",
				"allowOnloadGetList": false,
				"dataList": [],
				"sex_name": "",
				"address_ids": "",
				"switch_id": "",
				"is_change": "",
				"cancel_type": "1",
				"cancel_reason": "不想使用了",
				isSelect: false,
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			// let { is_change, cancel_type, cancel_reason } = options
			// if (is_change !== undefined) this.is_change = is_change
			// if (cancel_type !== undefined) this.cancel_type = cancel_type
			// if (cancel_reason !== undefined) this.cancel_reason = cancel_reason
			this.isSelect = options.iss == 1;
			uni.$on('UPDATE_ADDRESS_LIST', _ => this.getaddressFn())
		},
		onUnload() { uni.$off('UPDATE_ADDRESS_LIST') },
		methods: {
			closeModal() {
				console.debug('del')
				this.popupShow1698316415254 = false;
			},
			//抛出选择的地址
			handleClickFunc(aid) {
				if (!this.isSelect) return;
				const eventChannel = this.getOpenerEventChannel();
				eventChannel && eventChannel.emit('update', { address_id: aid });
				uni.navigateBack();
			},
			//地址管理-地址列表
			getListFunc() {
				this.minixPagingListsApi = global.apiUrls.post636f7683cf195;
				this.pageingListApiMethod = 'get';
				this.allowOnloadGetList = false;
				this.pagingListPostDataContent = {}
				this.listData = [];
				this.dataList = this.listData;
				this.pagingListToggle();
			},
			//获取地址id
			getAddressIdFunc(id) {
				this.address_ids = id;
				this.popupShow1698316415254 = true;
			},
			//删除地址
			async deleteAddressFunc() {
				uni.showLoading({ mask: true, title: '删除中' })
				try {
					await this.$post('6544d22133a68', { address_id: this.address_ids })
					this.getaddressFn()
					const eventChannel = this.getOpenerEventChannel();
					eventChannel && eventChannel.emit('remove', { address_id: this.address_ids });
				} catch (e) {}
				this.popupShow1698316415254 = false;
				uni.hideLoading();
			},
			//选择默认
			async SelectDefaultFunc(defaulitID, info = {}) {
				if (this.changeDefLoading) return;
				this.changeDefLoading = true;
				try {
					const status = Math.abs(info.is_default - 1);
					await this.$post("6544d20e1bbed", {
						...info,
						is_default: status,
					})
					this.addressData.map(item => {
						if (item.address_id == info.address_id)
							item.is_default = status;
						else item.is_default = false;
					})
				} catch (e) {}
				this.changeDefLoading = false;
				// if (defaulitid == 0) {
				// 	this.dataList.forEach(item => {
				// 		item.is_default = 0
				// 	})
				// 	//请求方法
				// 	//数据验证

				// 	let data6389ad65f28d9 = await this.$api.post(global.apiUrls.post6389ad65f28d9, {
				// 		address_id: defaulitID
				// 	});

				// 	if (data6389ad65f28d9.data.code != 1) {
				// 		this.$message.info(data6389ad65f28d9.data.msg);
				// 		return
				// 	}


				// 	this.dataList.forEach(item => {
				// 		if (item.aid == defaulitID) {
				// 			item.is_default = 1
				// 		}
				// 	})
				// 	this.$message.info('设置成功');
				// }
			},
			//发送注销
			async submitzxFunc() {
				//请求方法
				//数据验证

				let data637c4d70d3aa8 = await this.$api.post(global.apiUrls.post637c4d70d3aa8, {
					cancel_type: this.cancel_type,
					cancel_reason: this.cancel_reason
				});

				if (data637c4d70d3aa8.data.code != 1) {
					this.$message.info(data637c4d70d3aa8.data.msg);
					return
				}


				this.$urouter.redirectTo(`/pages/xitongs/logOutSubmit/logOutSubmit?type=1&status=`);
			},
			pagingListPostData() {
				return this.pagingListPostDataContent
			}
		}
	};
</script>

<style
	lang="scss"
	scoped
>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: url($imgFix + '583.png') no-repeat #fff;
		background-size: 100% auto;
	}

	.address_flex_0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/583.png) no-repeat;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.address_fd0_0_c1_c0 {
		font-size: 40rpx;
		font-weight: 400;
		color: #FFFFFF;
	}

	.address_fd0_0_c0_c0 {
		font-size: 38rpx;
		font-weight: 500;
		color: var(--benbenFontColor3);
	}

	.address_fd0_0_c0 {
		width: 180rpx;
	}

	.address_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.address_flex_1 {
		margin: 0rpx 0rpx 20rpx 0rpx;
		padding: 0 0 150rpx;
		box-sizing: border-box;
	}

	.address_fd1_1_c0 {
		background: var(--benbenbgColor2);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 36rpx;
		color: rgba(255, 255, 255, 1);
		width: 686rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 400;
	}

	.address_fd1_1 {
		width: 750rpx;
		position: fixed;
		left: 0rpx;
		bottom: calc(40rpx + var(--window-bottom));
	}

	.address_fd1_0_c0_c2_c1_c1 {
		margin: 0rpx 0rpx 0rpx 67rpx;
	}

	.address_fd1_0_c0_c2_c1_c0_c1 {
		line-height: 28rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
	}

	.address_fd1_0_c0_c2_c1_c0_c0 {
		width: 30rpx;
		height: 30rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 12rpx 0rpx 0rpx;
	}

	.address_fd1_0_c0_c2_c0_c1 {
		line-height: 32rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
	}

	.address_fd1_0_c0_c2_c0_c0 {
		width: 32rpx;
		height: 32rpx;
		margin: 0rpx 14rpx 0rpx 0rpx;
	}

	.address_fd1_0_c0_c2 {
		border-top: 1px solid #eee;
		padding: 26rpx 0rpx 0rpx 0rpx;
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.address_fd1_0_c0_c1_c0 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
	}

	.address_fd1_0_c0_c0_c5 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #1A1A1A;
		margin: 0rpx 0rpx 0rpx 24rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.address_fd1_0_c0_c0_c2 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #1A1A1A;
	}

	.address_fd1_0_c0_c0_c1 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #1A1A1A;
		max-width: 290rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.address_fd1_0_c0_c0_c0_c0 {
		color: #FFFFFF;
		font-size: 22rpx;
		font-weight: 400;
		line-height: 30rpx;
	}

	.address_fd1_0_c0_c0_c0 {
		border: 1px solid rgba(38, 114, 246, 1);
		background: #62889B;
		border-radius: 4rpx 4rpx 4rpx 4rpx;
		padding: 4rpx 10rpx 2rpx 10rpx;
		margin: 0rpx 14rpx 0rpx 0rpx;
	}

	.address_fd1_0_c0_c0 {
		padding: 0rpx 0rpx 20rpx 0rpx;
	}

	.address_fd1_0 {
		border: 1px solid #eee;
		background: #FFFFFF;
		background-size: 100% auto !important;
		margin: 0rpx 30rpx 20rpx 30rpx;
		padding: 32rpx 24rpx 32rpx 24rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.address_fd2_0_c0_c2_c1_c0 {
		color: #FFFFFF;
		font-size: 34rpx;
		font-weight: 400;
	}

	.address_fd2_0_c0_c2_c1 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/694.png) no-repeat;
		height: 71rpx;
		width: 191rpx;
		margin: 0rpx 0rpx 0rpx 16rpx;
		background-size: 100% auto;
	}

	.address_fd2_0_c0_c2_c0_c0 {
		color: #796446;
		font-size: 34rpx;
		font-weight: 400;
	}

	.address_fd2_0_c0_c2_c0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/693.png) no-repeat;
		height: 71rpx;
		width: 191rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
		background-size: 100% auto;
	}

	.address_fd2_0_c0_c2 {
		margin: 0rpx 0rpx 70rpx 0rpx;
	}

	.address_fd2_0_c0_c1 {
		line-height: 44rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
		margin: 40rpx 0rpx 71rpx 0rpx;
		text-align: center;
	}

	.address_fd2_0_c0_c0 {
		color: #333333;
		font-size: 40rpx;
		font-weight: 400;
		margin: 190rpx 0rpx 0rpx 0rpx;
	}

	.address_fd2_0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/692.png) no-repeat;
		width: 580rpx;
		background-size: 100% auto;
	}
</style>